/*
*Car.fx
*
*Created on Aug 7, 2011, 19:31:09 PM
*/

package derbyclnt;


import javafx.scene.CustomNode;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.Node;
import javafx.scene.transform.Rotate;
import derbyclnt.Logger.*;

public class Car extends CustomNode, derbyclnt.inter.ICar {
    public var clientId:Integer = -1;
	public var posX:Number = 0;
	public var posY:Number = 0;
	public var offsetX:Number = bind posX - img.width/2;
	public var offsetY:Number = bind posY - img.height/2;
	public var faceAngle:Number = 0;
	
	public var moveAngle: Number = 0;
    public var width:Number = bind img.width;
    public var height:Number = bind img.height;
    public var velocity:Number = 0;
	
	var img = Image {
	    url:"{__DIR__}car.png"
	} 
	var imgView = ImageView {
	    image:img
	    x: bind offsetX
	    y: bind offsetY
	    transforms: Rotate {
	        angle: bind faceAngle
	        pivotX: bind posX
	        pivotY: bind posY
	    }
	}
	
	override public function create(): Node {
	    logd("car was created!");
	    logd("__DIR__ constant = {__DIR__}");
	    return imgView;
	}
	
	/// INTERAPOBILITY ///
	
	override public function setPosX(posX_:Number):Void {
	    posX = posX_
	}
	override public function getPosX():Number {
	    return posX;
	}
	
	override public function setClientId(clientId_:Integer):Void {
	    clientId = clientId_;
	}
	override public function getClientId():Integer {
	    return clientId;
	}
	
	override public function setPosY(posY_:Number) : Void { 
		posY = posY_;
	}
	override public function getPosY():Number {
	    return posY;
	}
	
	override public function setFaceAngle(angle_:Number):Void {
	    faceAngle = angle_;
	}
	override public function getFaceAngle():Number {
	    return faceAngle;
	}
	
	override public function setMoveAngle(angle_:Number):Void {
	    moveAngle = angle_;
	}
	override public function getMoveAngle():Number {
	    return moveAngle;
	}
	
	
	override public function setVelocity(velocity_:Number):Void {
	    velocity = velocity_;
	}
	override public function getVelocity():Number {
	    return velocity;
	}
};
